/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-29 12:58:23
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-29 12:58:25
 * @Description: file content
 */
#include "apue.h"
#include <fcntl.h>

int set_cloexec(int fd)
{
    int val = fcntl(fd, F_GETFD, 0);
    if (val < 0)
    {
        return -1;
    }

    val |= FD_CLOEXEC;
    return fcntl(fd, F_SETFD, val);
}
